package com.huang.controller;

import com.huang.clients.ProductClient;
import com.huang.entity.Product;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import sun.rmi.runtime.Log;

import javax.annotation.Resource;
import java.util.Map;

@Slf4j
@RestController
public class UserController {

    @Value("${server.port}")
    private int port;
    @Resource
    private ProductClient productClient;

    @GetMapping("/user/find")
    public Map<String,Object> findProduct(@RequestParam("id") String id){
        Map<String, Object> map = this.productClient.find(id);

        return map;
    }
    @PostMapping("user/addProduct")
    public Map<String,Object> findProduct(@RequestBody Product product){
        Map<String, Object> map = this.productClient.add(product);
        log.info("进入用户服务端口号[{}]",port);
        return map;
    }
}
